]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Adjust to cursor tracker visibility API changes
authorSebastian Wick <sebastian.wick@redhat.com>
Wed, 25 Jun 2025 11:15:24 +0000 (13:15 +0200)
committerSebastian Wick <sebastian.wick@redhat.com>
Wed, 25 Jun 2025 11:15:24 +0000 (13:15 +0200)
The old `Meta.CursorTracker.set_pointer_visible` method has been
replaced by `inhibit_cursor_visibility` and
`uninhibit_cursor_visibility`.

Change the code to use the new API which makes the code more robust
because we don't have to listen for changes and then try to force it
back to what we want.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3772>

js/ui/magnifier.js
js/ui/screenShield.js

index 3b5c011a7b39048aeffa9594cea10e6a7fa30f68..386a8071cf992eaad337d913b3e0c2006565660a 100644 (file)
@@ -137,11 +137,9 @@ export class Magnifier extends Signals.EventEmitter {
             this._cursorUnfocusInhibited = false;
         }
 
-        if (this._cursorVisibilityChangedId) {
-            this._cursorTracker.disconnect(this._cursorVisibilityChangedId);
-            delete this._cursorVisibilityChangedId;
-
-            this._cursorTracker.set_pointer_visible(true);
+        if (this._cursorVisibleInhibited) {
+            this._cursorTracker.uninhibit_cursor_visibility();
+            this._cursorVisibleInhibited = false;
         }
     }
 
@@ -155,12 +153,9 @@ export class Magnifier extends Signals.EventEmitter {
             this._cursorUnfocusInhibited = true;
         }
 
-        if (!this._cursorVisibilityChangedId) {
-            this._cursorTracker.set_pointer_visible(false);
-            this._cursorVisibilityChangedId = this._cursorTracker.connect('visibility-changed', () => {
-                if (this._cursorTracker.get_pointer_visible())
-                    this._cursorTracker.set_pointer_visible(false);
-            });
+        if (!this._cursorVisibleInhibited) {
+            this._cursorTracker.inhibit_cursor_visibility();
+            this._cursorVisibleInhibited = true;
         }
     }
 
index 8867239d302526b9bff7120e30f3a905232c61ab..0ee1ce284b433c2288d93d5c281798c688bc4e4a 100644 (file)
@@ -369,7 +369,10 @@ export class ScreenShield extends Signals.EventEmitter {
     }
 
     _showPointer() {
-        this._cursorTracker.set_pointer_visible(true);
+        if (this._cursorVisibleInhibited) {
+            this._cursorTracker.uninhibit_cursor_visibility();
+            this._cursorVisibleInhibited = false;
+        }
 
         if (this._motionId) {
             global.stage.disconnect(this._motionId);
@@ -377,6 +380,13 @@ export class ScreenShield extends Signals.EventEmitter {
         }
     }
 
+    _hidePointer() {
+        if (!this._cursorVisibleInhibited) {
+            this._cursorTracker.inhibit_cursor_visibility();
+            this._cursorVisibleInhibited = true;
+        }
+    }
+
     _hidePointerUntilMotion() {
         this._motionId = global.stage.connect('captured-event', (stage, event) => {
             if (event.type() === Clutter.EventType.MOTION)
@@ -384,7 +394,7 @@ export class ScreenShield extends Signals.EventEmitter {
 
             return Clutter.EVENT_PROPAGATE;
         });
-        this._cursorTracker.set_pointer_visible(false);
+        this._hidePointer();
     }
 
     _hideLockScreen(animate) {